﻿namespace ChessToys
{
    using System;
    using System.Text;

    public class Rochade
    {
        private bool _whiteKingSide;
        private bool _whiteQueenSide;
        private bool _blackKindSide;
        private bool _blackQueenSide;

        public Rochade()
            : this(true, true, true, true)
        {
        }

        public Rochade(bool whiteKingSide, bool whiteQueenSide, bool blackKindSide, bool blackQueenSide)
        {
            _whiteKingSide = whiteKingSide;
            _whiteQueenSide = whiteQueenSide;
            _blackKindSide = blackKindSide;
            _blackQueenSide = blackQueenSide;
        }

        public Rochade(Rochade copy)
            : this(copy._whiteKingSide, copy._whiteQueenSide, copy._blackKindSide, copy._blackQueenSide)
        {
        }

        public bool WhiteKingSide
        {
            get { return _whiteKingSide; }
            set { _whiteKingSide = value; }
        }
        
        public bool WhiteQueenSide
        {
            get { return _whiteQueenSide; }
            set { _whiteQueenSide = value; }
        }

        public bool BlackKingSide
        {
            get { return _blackKindSide; }
            set { _blackKindSide = value; }
        }

        public bool BlackQueenSide
        {
            get { return _blackQueenSide; }
            set { _blackQueenSide = value; }
        }

        public override string ToString()
        {
            if (!WhiteQueenSide && !WhiteKingSide && !BlackQueenSide && !BlackKingSide)
            {
                return "-";
            }
            StringBuilder builder = new StringBuilder();
            if (WhiteKingSide)
            {
                builder.Append("K");
            }
            if (WhiteQueenSide)
            {
                builder.Append("Q");
            }
            if (BlackKingSide)
            {
                builder.Append("k");
            }
            if (BlackQueenSide)
            {
                builder.Append("q");
            }
            return builder.ToString();
        }
    }
}
